{% extends "base.html" %}

{% block content %}
<div class="jumbotron">
	<div class="container">
		<h1>Scoreboard</h1>
	</div>
</div>
<div class="container">
	{% if errors %}
	<div id='errors' class="row">
		<div class="col-md-12">
		{% for error in errors %}
			<h1 class="text-center">{{ error }}</h1>
		{% endfor %}
		</div>
	</div>
	{% else %}
		{% if score_frozen %}
		<div class="row">
			<div class="col-md-12">
				<h1 class="text-center">Scoreboard has been frozen.</h1>
			</div>
		</div>
		{% endif %}

		<div id="score-graph" class="row">
			<div class="col-md-12 text-center">
				<i class="fas fa-circle-notch fa-spin fa-3x fa-fw spinner"></i>
			</div>
		</div>

		{% if standings %}
		<div id="scoreboard" class="row">
			<div class="col-md-12">
				<table class="table table-striped">
					<thead>
						<tr>
							<td scope="col" width="10px"><b>Place</b></td>
							<td scope="col"><b>Team</b></td>
							<td scope="col"><b>Score</b></td>
						</tr>
					</thead>
					<tbody>
					{% for standing in standings %}
						<tr>
							<th scope="row" class="text-center">{{ loop.index }}</th>
							<td>
								<a href="{{ generate_account_url(standing.account_id) }}">
									{{ standing.name | truncate(50) }}

									{% if standing.oauth_id %}
										{% if get_config('user_mode') == 'teams' %}
										<a href="https://majorleaguecyber.org/t/{{ standing.name }}">
											<span class="badge badge-primary">Official</span>
										</a>
										{% elif get_config('user_mode') == 'users' %}
										<a href="https://majorleaguecyber.org/u/{{ standing.name }}">
											<span class="badge badge-primary">Official</span>
										</a>
										{% endif %}
									{% endif %}
								</a>
							</td>
							<td>{{ standing.score }}</td>
						</tr>
					{% endfor %}
					</tbody>
				</table>
			</div>
		</div>
		{% endif %}
	{% endif %}
</div>
{% endblock %}

{% block scripts %}
	<script src="{{ url_for('views.themes', path='js/vendor/plotly.min.js') }}"></script>
	<script src="{{ url_for('views.themes', path='js/utils.js') }}"></script>
	<script src="{{ url_for('views.themes', path='js/scoreboard.js') }}"></script>
{% endblock %}
